package cn.ava.pet.controller;

import cn.ava.pet.service.ISearchMasterMsgRejectLogService;
import cn.ava.pet.domain.SearchMasterMsgRejectLog;
import cn.ava.pet.query.SearchMasterMsgRejectLogQuery;
import cn.ava.basic.utils.AjaxResult;
import cn.ava.basic.utils.PageList;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/searchMasterMsgRejectLog")
public class SearchMasterMsgRejectLogController {

    @Autowired
    private  ISearchMasterMsgRejectLogService searchMasterMsgRejectLogService;


    /**
     * 保存和修改公用的
     * @param searchMasterMsgRejectLog  传递的实体
     * @return Ajaxresult转换结果
     */
    @PutMapping
    public AjaxResult addOrUpdate(@RequestBody SearchMasterMsgRejectLog searchMasterMsgRejectLog){
        try {
            if( searchMasterMsgRejectLog.getId()!=null)
                searchMasterMsgRejectLogService.update(searchMasterMsgRejectLog);
            else
                searchMasterMsgRejectLogService.add(searchMasterMsgRejectLog);
            return new AjaxResult();
        } catch (Exception e) {
            e.printStackTrace(); 
            return new AjaxResult().setMessage("服务器崩溃！").setSuccess(false);
        }
    }
    /**
    * 删除对象信息
    * @param id
    * @return
    */
    @DeleteMapping(value="/{id}")
    public AjaxResult delete(@PathVariable("id") Long id){
        try {
            searchMasterMsgRejectLogService.delete(id);
            return new AjaxResult();
        } catch (Exception e) {
        e.printStackTrace();
            return new AjaxResult().setMessage("服务器崩溃！").setSuccess(false);
        }
    }
	
    //获取用户
    @GetMapping("/{id}")
    public SearchMasterMsgRejectLog getById(@PathVariable("id")Long id)
    {
        return searchMasterMsgRejectLogService.getById(id);
    }


    /**
    * 查看所有的员工信息
    * @return
    */
    @GetMapping()
    public List<SearchMasterMsgRejectLog> list(){

        return searchMasterMsgRejectLogService.loadAll();
    }


    /**
    * 分页查询数据
    *
    * @param query 查询对象
    * @return PageList 分页对象
    */
    @PostMapping()
    public PageList<SearchMasterMsgRejectLog> json(@RequestBody SearchMasterMsgRejectLogQuery query)
    {
        return searchMasterMsgRejectLogService.queryData(query);
    }
}
